<%@ page language="java" contentType="text/html;charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath %>">
<title><s:text name="sys.app_title" /></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="../include/contentheader.jsp"%>
<link rel="stylesheet" rev="stylesheet" href="css/style.css" type="text/css" media="all" />
<link rel="stylesheet" type="text/css" href="css/main.css"/>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
</head>
<script type="text/javascript">
	$(document).ready(function(){
		$('#submit').click(function(){
			vali();
			var userName = $('#up_userName');
			var newPwd = $('#newPwd');
			var SnewPwd = $('#sNewPwd');
			var oldPwd = $('#oldPwd');
			if(userName.val()==''){
				vali();
				$("#userName_meg").prepend("<font color='red'>请输入您的账号!</font>");
			}else if(oldPwd.val()==''){
				vali();
				$("#oldPwd_meg").prepend("<font color='red'>请输入您的原始密码!</font>");
			}else if(newPwd.val()==''){
				vali();
				$("#newPwd_meg").prepend("<font color='red'>新密码不能为空!</font>");
			}else if(SnewPwd.val()==''){
				vali();
				$("#SnewPwd_meg").prepend("<font color='red'>请再次输入密码!</font>");
			}else if(newPwd.val() != SnewPwd.val()){
					vali();
					$('#SnewPwd_meg').prepend("<font color='red'>确认密码与新密码不匹配,请重新输入!</font>");
			}else{
				var cs = {up_userName:userName.val(),newPwd:newPwd.val()};
				$.post('updateUserPwd.action',cs,,'json');
			}
		});

		function vali(){
			$("#userName_meg").empty();
			$("#oldPwd_meg").empty();
			$("#newPwd_meg").empty();
			$("#SnewPwd_meg").empty();
		}
	});
</script>
<body class="ContentBody">
	<form action="updateUserPwd.action" method="post">
	<div class="MainDiv">
	<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		<tr>
			<th class="tablestyle_title" >个人密码管理</th>
		</tr>
		<tr>
		    <td class="CPanel">
				<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
				<tr>		
				   <td width="100%">
					  	<fieldset style="height:100%;">
						<legend>账号信息</legend>			      
							<table align="center" border="0" cellpadding="2" cellspacing="1" style="width:100%">
							  <tr>
							  	<td style="width: 33%">
								  	<input type="hidden" name="u" id="us" value=""/>账号：
								</td>
								<td style="width: 33%">
							  		<input type="text" name="up_userName" id="up_userName" value="" />
							  	</td>
							  	<td style="width: 33%"><span id="userName_meg"></span></td>
							  </tr>
							  <tr>
							  	<td>原始密码：</td>
							  	<td>
							  		<input type="text" name="oldPwd" id="oldPwd" value="" />
							  	</td>
							  	<td><span id="oldPwd_meg"></span></td>
							  </tr>
							  <tr>
							  	<td>新密码：</td>
							  	<td>
							  		<input type="text" name="newPwd" id="newPwd" value="" />
							  	</td>
							  	<td><span id="newPwd_meg"></span></td>
							  </tr>
							  <tr>
							  	<td>确认新密码：</td>
							  	<td>
							  	<input type="text" name="sNewPwd" id="sNewPwd" value="" />
							  	</td>
							  	<td><span id="SnewPwd_meg"></span></td>
							  </tr>
							  <tr>
							  	<td colspan="3">
							  		<center>
							  		<s:actionmessage cssClass=""/>
							  			<s:actionmessage cssClass="login_error" />
							  		</center>
							  	</td>
							  </tr>
							</table>
					  		<br />
						</fieldset>	
					</td>
				</tr>
				</table>
			</td>
		</tr>			
		<tr>
			<td colspan="3" align="center" height="50px">
			<input type="submit" name="Submit" id="submit" value="保存" />
			<input type="button" name="Submit2" value="返回" onclick="window.history.go(-1);"/>
			</td>
		</tr> 
	</table>
	</div>
	</form>
</body>
</html>